package top.codetheory._03_栈;

import top.codetheory._01_动态数组.List;
import top.codetheory._02_链表.LinkedList;

/**
 * @author:
 * @since: 2023/11/23 14:38
 **/
public class Stack<E> {
    private List<E> list = new LinkedList<>();

    public void clear() {
        list.clear();
    }

    public int size() {
        return list.size();
    }

    public boolean isEmpty() {
        return list.isEmpty();
    }

    public void push(E element) {
        list.add(element);
    }

    public E pop() {
        return list.remove(list.size() - 1);
    }

    public E top() {
        return list.get(list.size() - 1);
    }
}